# import time
#
# class Phone(object):#一般类名首
#
#     serial_no=10000
#     phonelist=[]
#
#     @classmethod
#     def count(cls):
#         return len(cls.phonelist)
#
#     def __init__(self):
#         self.mask='钢化膜'
#         self.color='red'
#         self.no=Phone.serial_no
#         Phone.phonelist.append(self.no)
#         Phone.serial_no+=1
#
#     def call(self,number):#在工厂中定义
#         taketime=1
#         time.sleep(taketime)
#         print(f"---拨通电话{number}--—-")
#         return taketime
#
#     def sendMeg(self):
#         print( "---发送短信----")
#
#     # def __del__(self):
#     #     print(self.no,'我走了哟！')
#
#     def __str__(self):
#         return f'我的编号是{self.no},贴的{self.mask},颜色是{self.color}'
#
# p1=Phone()
# p2=Phone()
# p3=Phone()
# a=Phone()
# b=Phone()
# c=Phone()
# p1.no=123456
# p2.no=654321
# p1.call(123456)
# print(p1.mask,p1.color)
# print(p1)
# print(p2,p3)
# print(a,b,c)
# print(Phone.phonelist,Phone.count())



# if hasattr(p1,'mask'):
#     print(f'已经贴膜 {p1.mask}')
# else:
#     print(f'没有贴膜',p1.mask)





# class FirstClass(object):
#     name='zhangsan'
#     age=22
#     def print_info(self):
#         print(f'姓名为{self.name}，年龄为{self.age}')
#
# x = FirstClass()  # 注意一定要加括号
# print(f'访问属性：{x.name},{x.age}')
# x.print_info()



# class Province(object):
#     # 类属性
#     country='china'
#     def __init__(self,name):
#         # 实例属性
#         self.name = name
#
# obj_chengdu = Province('ChengDu')
# print(obj_chengdu.name)  # 使用对象访问实例属性
# print(Province.country)  # 使用类访问类属性


# class Foo(object):
#     def ord_fun(self,name):
#         print(name)
#
#     @staticmethod
#     def ststic_func(arg):
#         print(arg)
#
#     @classmethod
#     def class_fanc(cls):
#         print(cls)
#
# a=Foo()
# a.ord_fun('xinyi')
# a.ststic_func('asdfghjk')
# Foo.ststic_func('cvbnm')
# Foo.class_fanc()




# 1.  所有学生来自成都”
# 2.  能打印有那些学生姓名、学号
# 3.  能打印一共有几名学生
# 4.  打印学生对象，显示姓名和学号
# 5.  每个学生都有学习的方法
# 6.  学号不能重复。  ---> 看看能不能用数字加法做出来。
# 7.  每个学生都有学号和姓名

# class Student(object):
#     stu_list=[]
#     id=10000
#
#     @classmethod
#     def all_stu(cls):
#         print(f'有这些学生：{cls.stu_list}')
#     @classmethod
#     def count(cls):
#         print(f'共有{len(Student.stu_list)}名学生。')
#     def __init__(self,name):
#         addr = '成都'
#         self.name=name
#         self.id=Student.id
#         Student.id += 1
#         Student.stu_list.append({'name':self.name,'id':self.id})
#     def __str__(self):
#         return f'姓名：{self.name}，学号：{self.id}'
#     def learn(self, kw):
#         print(f"---学习{kw}---")
#
# s1=Student('张三')
# s2=Student('李四')
# s3=Student('王五')
# s4=Student('xiaoq')
# s5=Student('xiny')
# Student.all_stu()
# Student.count()
# print(s2)
# s1.learn("语文")



# class Student(object):
#     def __init__(self):
#         self.name='小明'
#         self.__age=22
#         # self.__red()
#
#     def __red(self):
#         print(self.name+'在读书')
#
#     def age(self):
#         print(f'{self.name}今年{self.__age}岁。')
#
# s = Student()
# print(s._Student__age)


class MyTest(object):
    __class_attr="类属性"

    @classmethod
    def class_method(cls):
        print("类方法")
        print(MyTest.__class_attr)
    @staticmethod
    def static_method():
        print("静态方法")
        # print(MyTest.class_attr)
        # MyTest.class_method()
    def self_method(self):
        # print(MyTest.class_attr)
        # print(self.class_attr)
        # MyTest.class_method()
        # self.class_method()
        # MyTest.static_method()
        # self.static_method()
        self.__a='实例属性'
        print(self.__a)

    def __init__(self):
        self.__b='实例属性'

MyTest.class_method()
a=MyTest()
a.self_method()























